#include <stdint.h>
#include "value.h"

uint8_t *swap_byte(uint8_t *ptr, size_t size) {
	int i;
	uint8_t tmp;

	for (i = 0; i < size; i += 2) {
		tmp = ptr[i];
		ptr[i] = ptr[i + 1];
		ptr[i + 1] = tmp;
	}

	return ptr;
}

uint16_t *swap_word(uint16_t *ptr, size_t size) {
	int i;
	uint16_t tmp;

	for (i = 0; i < size; i += 2) {
		tmp = ptr[i];
		ptr[i] = ptr[i + 1];
		ptr[i + 1] = tmp;
	}

	return ptr;
}

uint32_t *swap_dword(uint32_t *ptr, size_t size) {
	int i;
	uint32_t tmp;

	for (i = 0; i < size; i += 2) {
		tmp = ptr[i];
		ptr[i] = ptr[i + 1];
		ptr[i + 1] = tmp;
	}

	return ptr;
}